<template>
	<view id="container">
		<view id="icon">
			<image src="../../static/logo.png" mode="aspectFit"></image>
		</view>
		<view id="login-form-container">
			<form id="login-form" @submit="handleSubmit" @reset="handleReset">
				<view class="form-item">
					<text>账号</text>
					<input name="username" class="uni-input" value="liqing" />
				</view>
				<view class="form-item">
					<text>密码</text>
					<input name="password" class="uni-input" value="123456" />
				</view>
				<view class="form-item">
					<button form-type="submit" type="primary">登录</button>
				</view>
			</form>
		</view>
	</view>
</template>

<script>
	import { setToken, getToken } from '../../util/token.js'
	export default {
		data () {
			return {
				
			}
		},
		methods: {
			handleSubmit(e) {
				let data = {...e.detail.value};
				this.$api.login(data).then(res => {
					setToken(res);
					uni.reLaunch({
						url: '../question/question'
					})
				})
			},
			handleReset(e) {
				console.log(e);
			}
		}
	}
</script>

<style scoped>
	#container {
		width: 100%;
		height: 100%;
	}
	#icon, #login-form {
		width: 100%;
		text-align: center;
	}
	.form-item {
		padding: 20rpx;
	}
	#icon image {
		height: 100px;
		margin: 20px auto;
	}
	.uni-input {
		border: 1px solid #0A98D5;
		border-radius: 10rpx;
	}
</style>
